use super::FudaThing;
use serde::Deserialize;
use serde::Serialize;
use surrealdb::sql::Thing;
use ts_rs::TS;

use derive_more::Display;

///
/// 访问历史
///
#[derive(Debug, Serialize, Deserialize, Default, TS, Clone)]
#[ts(export)]
pub struct FudaHistory {
    /// TradeOrder Id, 自动创建
    #[ts(as = "Option<FudaThing>")]
    pub id: Option<Thing>,

    ///
    /// enitity type, primary key
    ///
    pub entity_type: Option<EntityType>,
    ///
    /// entity_id, primary key
    ///
    pub entity_id: Option<String>,

    /// entity name
    ///
    pub entity_name: Option<String>,

    /// 访问时间戳
    pub tstamp: Option<String>,

    /// 记录更新日期 HLC
    pub last_updated: Option<String>,
}

#[derive(Display, Debug, Serialize, Deserialize, Default, TS, Clone, PartialEq)]
#[serde(rename_all = "UPPERCASE")]
#[ts(export)]
pub enum EntityType {
    /// Auto
    Tbot,
    /// manual
    #[default]
    Security,
}
